pub mod controller;
pub mod dao;
pub mod db;
pub mod model;
pub mod service;
pub mod utils;

use std::sync::{Arc, Mutex};

use actix_web::{body::BoxBody, http::header::ContentType, HttpRequest, HttpResponse, Responder};
use serde::Serialize;

#[derive(Serialize)]
pub struct BestDataHttpResponce<T: Serialize> {
    code: i32,
    message: &'static str,
    data: T,
}

// Responder
impl<T: Serialize> Responder for BestDataHttpResponce<T> {
    type Body = BoxBody;

    fn respond_to(self, _req: &HttpRequest) -> HttpResponse<Self::Body> {
        let body = serde_json::to_string(&self).unwrap();

        // Create response and set content type
        HttpResponse::Ok()
            .content_type(ContentType::json())
            .body(body)
    }
}

pub struct AppState {
    pub connections: Mutex<u32>,
    pub seq: Arc<db::Seq>,
}
